package com.wyl.dao

import com.wyl.utils.getSqlSession
import org.apache.log4j.Logger
import org.junit.Test
import kotlin.math.max

class UserMapperTest {
    private val logger = Logger.getLogger(UserMapperTest::class.java)

    @Test
    fun testGetUserList() {
        getSqlSession().use {
            val mapper = it.getMapper(UserMapper::class.java)
            mapper.getUserList().forEach(::println)
        }
    }

    @Test
    fun testLog4J() {
        logger.info("info: testLog4J")
        logger.debug("debug: testLog4J")
        logger.error("error: testLog4J")
    }

    @Test
    fun testGetUserByLimit() {
        val page = 1
        val size = 2
        getSqlSession().use {
            val mapper = it.getMapper(UserMapper::class.java)
            mapper.getUserByLimit(
                hashMapOf(
                    "page" to max(page - 1, 0) * size,
                    "size" to size
                )
            ).forEach(::println)
        }
    }

    fun testGetUserByByRowBounds() {

    }
}